import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Solution823 {
    public int numFactoredBinaryTrees(int[] arr) {
        int mod=1000000007;
        Arrays.sort(arr);
        Map<Integer,Integer> map=new HashMap<>();
        for (int i=0;i<arr.length;i++){
            map.put(arr[i],i);
        }
        long[] f=new long[arr.length];
        Arrays.fill(f,1);
        for (int i=0;i<arr.length;i++){
            for (int j=0;j<=i;j++){
                if ((long)arr[i]*arr[j]<=Integer.MAX_VALUE && map.containsKey(arr[i]*arr[j])){
                    int t=map.get(arr[i]*arr[j]);
                    if (i==j){
                        f[t]=(f[t]+(f[i]*f[i]%mod))%mod;
                    }else{
                        f[t]=(f[t]+(f[i]*f[j]%mod*2%mod))%mod;
                    }
                }
            }
        }
        long sum=0;
        for (long l : f) {
            sum=(sum+l)%mod;
        }
        return (int)sum;
    }

    public static void main(String[] args) {
        System.out.println(new Solution823().numFactoredBinaryTrees(new int[]{18,3,6,2}));
    }
}
